package org.idea.spring.framework.mybatis.factorybean;

import org.apache.ibatis.session.SqlSession;
import org.idea.spring.framework.mybatis.mapper.UserMapper;
import org.springframework.beans.factory.FactoryBean;

/**
 * @Author linhao
 * @Date created in 9:40 上午 2021/6/5
 */
public class MapperFactoryBean implements FactoryBean {

    private SqlSession sqlSession;

    public MapperFactoryBean(SqlSession sqlSession){
        this.sqlSession = sqlSession;
    }

    @Override
    public Object getObject() throws Exception {
        return sqlSession.getMapper(UserMapper.class);
    }

    @Override
    public Class<?> getObjectType() {
        return UserMapper.class;
    }
}
